﻿using System.Text;
using NUnit.Framework;
using Shinkansen.Core;
using Shinkansen.Support;

namespace Shinkansen.Test
{
    [TestFixture]
    public class HttpCompressionTest
    {
        [Test]
        public void Gzip_compresses_from_plain_text ()
        {
            string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit";
            HttpCompressor compressor = new HttpCompressor (HttpCompressionMode.GZip);

            string result = compressor.Compress (text);
            Assert.IsNotNullOrEmpty (result);
        }
        
        [Test]
        public void Gzip_compresses_from_encoded_text ()
        {
            string          text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit";
            byte[]          encoded = Encoding.UTF8.GetBytes (text);
            HttpCompressor  compressor = new HttpCompressor (HttpCompressionMode.GZip);

            byte[] result = compressor.Compress (encoded);

            Assert.IsNotNull (result);
            Assert.IsNotEmpty (result);
        }


        [Test]
        public void Deflate_compresses_from_plain_text ()
        {
            string          text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit";
            HttpCompressor  compressor = new HttpCompressor (HttpCompressionMode.Deflate);

            string result = compressor.Compress (text);
            Assert.IsNotNullOrEmpty (result);
        }

        [Test]
        public void Deflate_compresses_from_encoded_text ()
        {
            string          text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit";
            byte[]          encoded = Encoding.UTF8.GetBytes (text);
            HttpCompressor  compressor = new HttpCompressor (HttpCompressionMode.Deflate);

            byte[] result = compressor.Compress (encoded);

            Assert.IsNotNull (result);
            Assert.IsNotEmpty (result);
        }

    }
}
